
import { put, takeEvery,take,fork } from 'redux-saga/effects';
import * as actionTypes from './action-types';
const delay = (ms)=>{
    return new Promise(resolve=>{
        setTimeout(resolve,ms);
    });
}
export function* workerSaga() {
    console.log('-----workerSaga  开始----------');
    yield delay(1000);
    yield put({ type: actionTypes.ADD });
    console.log('-----workerSaga  结束----------');

}
function * watcherSaga(){
    console.log('-----watcherSaga  开始----------');
    const action = yield take(actionTypes.ASYNC_ADD);
    yield fork(workerSaga);
    console.log('-----watcherSaga   结束----------');

}
export default function* rootSaga() {
    console.log('-----rootSaga  开始----------');
   yield watcherSaga();
   console.log('-----rootSaga  结束----------');

}